package com.sinosoft.bee.services.cousumerwithfeign.demo.interfaces;

import com.sinosoft.bee.services.cousumerwithfeign.config.BeeProviderDemoConfiguration;
import com.sinosoft.bee.services.cousumerwithfeign.demo.annotations.WrongSample;
import com.sinosoft.bee.services.cousumerwithfeign.demo.controller.ResultVO;
import feign.Body;
import feign.Headers;
import feign.Param;
import feign.RequestLine;
import org.springframework.cloud.netflix.feign.FeignClient;

/**
 * @author:TobbyQuinn
 * @date:2018/4/26
 * @project:bee
 *
 *
 * 默认使用的是ribbon的轮询策略
 **/
@FeignClient(value = "bee-provider-demo",configuration = BeeProviderDemoConfiguration.class)
public interface BeeProviderDemoService {
    /**
     * 测试get请求
     * @param id
     * @return
     */
    @RequestLine("GET /provider/{id}")
    ResultVO getFromProvider1(@Param("id") long id);

    /**
     * 测试post请求
     * @param id
     * @return
     */
    @RequestLine("POST /provider/{id}")
    @WrongSample
    ResultVO getFromProvider2(@Param("id") long id);

    @RequestLine("POST /provider2")
    @Headers("Content-Type: application/json")
    // json curly braces must be escaped!
    @Body("%7B\"id\": \"{id}\"%7D")
    ResultVO getFromProvider3(@Param("id") long id);

}
